package cn.lds.j367.dsbank.common.dto;

import cn.lds.j367.dsbank.common.dsenum.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ResultDTO<T> {

    private Integer code;
    private String msg;
    private T obj;

    public static ResultDTO buildSuccess(){
        return new ResultDTO(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(),null);
    }

    public static ResultDTO buildSuccess(Object o){
        return new ResultDTO(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(),o);
    }

    public static ResultDTO buildSuccess(String msg,Object o){
        return new ResultDTO(ResultEnum.SUCCESS.getCode(), msg,o);
    }

    public static ResultDTO buildError(){
        return new ResultDTO(ResultEnum.ERROR.getCode(), ResultEnum.ERROR.getMsg(), null);
    }

    public static ResultDTO buildError(String msg){
        return new ResultDTO(ResultEnum.ERROR.getCode(),msg, null);
    }


}
